<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<a id="search" class="mui-icon mui-icon mui-icon-right-nav mui-pull-right" style="font-size: 16px;line-height: 25px;">搜索</a>
			<h1 class="mui-title">添加好友</h1>
		</header>

		<div class="mui-content">
			<div class="mui-input-row">
				<input id="friendName" type="text" class="mui-input-clear" placeholder="搜索好友">
			</div>

		</div>

		<script src="js/mui.min.js"></script>
		<script src="js/common.js"></script>
		<script type="text/javascript">
			mui.init();

			mui.plusReady(function() {

				var friendName = document.getElementById("friendName");
				friendName.value = "";
				
				var search = document.getElementById("search");

				search.addEventListener("tap", function() {
					var user = util.getUser();
					
					util.ajax("/user/findByUserName?userid=" + user.id + "&friendUsername=" + friendName.value, {
						},
						function(data) {
							console.log(JSON.stringify(data));
							if(data.success) {
								mui.openWindow({
									url: "search_friend_result.html",
									id: "search_friend_result",
									extras: {
										friend: data.data,
									},
								});
								console.log(friend)
							}
							
							else {
								mui.toast(data.message);
							}
						});
				})
			});
		</script>
	</body>

</html>